<?php
include "conn.php";
$art = showAllOfBlog(1);
$thead = ['标题', '发布时间', '作者', '操作'];
?>


<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>管理博客</title>

</head>
<body>
<header>
    <ul class="nav">
        <li><a href="index.php" target="_self">返回首页</a></li>
        <li><a href="manageBlog.php" target="_self">已发布</a></li>
        <li><a href="showDeleteBlog.php" target="_self">已删除</a></li>
    </ul>
</header>
<div class="table-container">
    <table>
        <thead>
        <tr>
            <?php foreach ($thead as $item): ?>
                <th><?php echo $item; ?></th>
            <?php endforeach; ?>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($art as $item): ?>
            <tr>
                <?php $id = $item['id_blog'] ?>
                <td><?php echo $item['title'] ?></td>
                <td class="publish-td"><?php echo $item['publish'] ?></td>
                <td class="author-td"><?php echo $item['author'] ?></td>
                <td>
                    <a href="restoreBlog.php?id=<?php echo $id ?>">恢复</a>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>

<style>
    header {
        background-color: aqua;
        height: 50px;
    }

    .nav {
        height: 100%;
        display: flex;
        padding: 0 20%;
    }

    .nav li {
        margin: 2px;
        list-style: none;
        width: 50%;
        align-items: center;
        display: flex;
        background-color: azure;
        justify-content: center;
    }

    .nav li a {
        text-decoration: none;
    }

    .table-container {
        display: flex;
        margin-top: 5px;
        justify-content: center;
        border: deeppink solid 2px;
    }

    table {
        width: 540px;
        margin-top: 5px;
        border: red solid 2px;
    }

    thead {
        font-weight: bold;
        border: deeppink solid 2px;
    }

    .publish-td {
        text-align: center;
    }

    .author-td {
        text-align: center;
    }
</style>
